import plugin from '../../lib/plugins/plugin.js'
import common from "../../lib/common/common.js"
const _path = process.cwd();

/**
 作者：摆烂煌(2608259582)
 编写于：2023/01/14-09:00
 最近修改：2023/09/05-00:20
 别问，问就是群(695596638)
 纠正名称部分原作者：西北一枝花（1679659）.
 **/

//使用前请确认Yunzai/config/config/group.yaml文件里的botAlias未填写与下方相同的Bot名称.

let botname = '小凛' // 此处修改为自己的Bot名字.
let jzhz = '(lin)'// 此处修改成自己Bot名字最后一字的谐音，多个用'|'隔开，不要删括号！！！.

//本地图片.
//${_path}表示云崽目录，自行选择图片存放路径.
let img_1 = `file://${_path}/resources/img/img_1.gif`
let img_2 = `file://${_path}/resources/img/img_2.png`
let img_3 = `file://${_path}/resources/img/img_3.gif`
let img_4 = `file://${_path}/resources/img/img_4.png`
let img_5 = `file://${_path}/resources/img/img_5.gif`
let img_6 = `file://${_path}/resources/img/img_6.gif`
let img_7 = `file://${_path}/resources/img/img_7.gif`
//1-7为名称回复，8-17为纠正名称.
let img_8 = `file://${_path}/resources/img/img_8.png`
let img_9 = `file://${_path}/resources/img/img_9.gif`
let img_10 = `file://${_path}/resources/img/img_10.png`
let img_11 = `file://${_path}/resources/img/img_11.png`
let img_12 = `file://${_path}/resources/img/img_12.png`
let img_13 = `file://${_path}/resources/img/img_13.png`
let img_14 = `file://${_path}/resources/img/img_14.png`
let img_15 = `file://${_path}/resources/img/img_15.png`
let img_16 = `file://${_path}/resources/img/img_16.png`
let img_17 = `file://${_path}/resources/img/img_17.gif`

export class example extends plugin {
  constructor() {
    super({
      name: '名称回复',
      dsc: '回复图文及纠正名称',
      event: 'message',
      priority: 500,
      rule: [{
        reg: `^#?(在)?(吗|干吗|干嘛|哪|那|哪里|那里|么)?(丫|鸭|呀|呐|呢|喵)?[~～.。,，!！、？]?${botname}(在|出来)?(吗|干吗|干嘛|哪|那|哪里|那里|么)?(丫|鸭|呀|呐|呢|喵)?[~～.。,，!！、？]?$`,
        fnc: 'huifu'
      }, {
        reg: '^#*[\u4e00-\u9fa5]+' + jzhz + '$',
        fnc: 'jiuzheng'
      }]
    })
  }

  async huifu(e) {
    let number = Math.round(Math.random() * 100 + 1)
    let msg = ''
    if (number < 15) {
      msg = [`来了来了，${botname}一直在呢~\n`,
      segment.image(`${img_1}`)]
    } else if (number < 30) {
      msg = [`你喊${botname}做什么，${botname}也是很忙的好吧！\n`,
      segment.image(`${img_2}`)]
    } else if (number < 45) {
      msg = [`${botname}在哦，有啥事?\n`,
      segment.image(`${img_3}`)]
    } else if (number < 60) {
      msg = [segment.image(`${img_4}`)]
    } else if (number < 75) {
      msg = [`来啦~\n`,
        segment.image(`${img_5}`)]
    } else if (number < 90) {
      msg = [`你好烦丫，${botname}不就在这吗?\n`,
      segment.image(`${img_6}`)]
    } else {
      await this.reply('我——！')
      await common.sleep(300)
      await this.reply('在——！')
      await common.sleep(300)
      await this.reply('呢——！')
      await common.sleep(300)
      await this.reply([segment.image(`${img_7}`)])
      return true
    }
    await this.reply(msg)
    return true
  }

  async jiuzheng(e) {
    let char = e.toString()
    let charArr = char.split('').join('——')
    let botArr = botname.split('').join('——')
    let number = Math.round(Math.random() * 100 + 1)
    let msg = ''
    if (number < 10) {
      msg = [`是${botname}啦！气气，哼>_<`,
      segment.image(`${img_8}`)]
    } else if (number < 20) {
      msg = [`${charArr}——是——谁——啦~`,
      segment.image(`${img_9}`)]
    } else if (number < 30) {
      msg = [`是${botname}好叭！！！`,
      segment.image(`${img_10}`)]
    } else if (number < 40) {
      msg = [`哎呀~才不是什么${char}！！！`,
      segment.image(`${img_11}`)]
    } else if (number < 50) {
      msg = [`${char}是什么？可以吃吗？`,
      segment.image(`${img_12}`)]
    } else if (number < 60) {
      msg = [`不许叫我${char}啦！！！`,
      segment.image(`${img_13}`)]
    } else if (number < 70) {
      msg = [`笨比，人家明明叫${botname}！！！`,
      segment.image(`${img_14}`)]
    } else if (number < 80) {
      msg = [`小黑子什么意思，连“${botname}”俩字都能打错?`,
      segment.image(`${img_15}`)]
    } else if (number < 90) {
      msg = [`人家叫${botname}，才不是什么${char}！！！`,
      segment.image(`${img_16}`)]
    } else {
      await this.reply('我——是——！！')
      await common.sleep(300)
      await this.reply(`${botArr}——！！`)
      await common.sleep(300)
      await this.reply('气——气——！！')
      await common.sleep(300)
      await this.reply([segment.image(`${img_17}`)])
      return true
    }
    await this.reply(msg)
    return true
  }
}